<?php
/**
 * @author by bilee.
 * 时间: 17/2/15 下午4:58
 * 跑客金额变动表
 */

namespace Common\Model;

use Common\Model\CommonModel;

class DispatchBalanceModel extends CommonModel
{
    /**获取今日收入
     * @param $dispatch_id
     * @return int
     */
    public function get_today_money($dispatch_id)
    {
        $map['dispatch_id'] = $dispatch_id;
        $map['time'] = array('like', date('Y-m-d') . '%');
        
        $ret_balance = $this->where($map)->field('balance_amount,balance_type')->select();

        $dayCount = 0;
        if ($ret_balance) {
            for ($i = 0; $i < count($ret_balance); $i++) {
                if ($ret_balance[$i]['balance_type'] == 1 || $ret_balance[$i]['balance_type'] == 3 || $ret_balance[$i]['balance_type'] == 5 || $ret_balance[$i]['balance_type'] == 10) {
                    $dayCount += $ret_balance[$i]['balance_amount'];
                }
            }
        }
        $dayCount = number_format($dayCount,2);
        return $dayCount;
    }

    function test(){
        return 1;
    }

}